<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<?php 
	redirect(site_url("escorts/account/services"));
	exit();
	
	$subscriptionArray = array(); 
	$subsJsonArray = array();
	foreach(getSubcriptionData_ioc() as $key=>$arrayValue){
		$subscriptionArray[$key] =  $arrayValue[0].' '.$arrayValue[1].' &euro;';
		$subsJsonArray[$key] = $arrayValue[1];
	}
	 
	$listPlaceArray = array();
	$placeJsonArray = array();
	foreach(getPlaceListWorkData_ioc() as $key=>$arrayValue){
		$listPlaceArray[$key] = $arrayValue[0].' '.$arrayValue[1].' &euro;';
		$placeJsonArray[$key] = $arrayValue[1];
	}
	
	$listPackArray = array();
	$packJsonArray = array();
	foreach(getPackListData_ioc() as $key=>$arrayValue){
		$listPackArray[$key] = $arrayValue[0].' '.$arrayValue[1].' &euro;';
		$packJsonArray[$key] = $arrayValue[1];
	}
	
	$listPriorityArray = array();
	$priorityJsonArray = array();
	foreach(getPriorityData_ioc() as $key=>$arrayValue){
		$listPriorityArray[$key] = $arrayValue[0].' '.$arrayValue[1].' &euro;';
		$priorityJsonArray[$key] = $arrayValue[1];
	}
?>

<script type="text/javascript">
	var subs = JSON.parse('<?php echo json_encode($subsJsonArray);?>');
	var place = JSON.parse('<?php echo json_encode($placeJsonArray);?>');
	var pack = JSON.parse('<?php echo json_encode($packJsonArray);?>');
	var priority = JSON.parse('<?php echo json_encode($priorityJsonArray);?>');
	var EURO_MONTHLY = ' <?php echo language_translate('services_page_euro_monthly');?>';
	function returnValueJSON(json,key){
		return parseFloat( json[key] );
	}
</script>


<form action="<?php echo site_url('registration/submit_step2');?>" name="user_form" id="user_form" method="post" enctype="multipart/form-data" >

<div class="home-escort-list">
	<span style="line-height:30px;"><?php echo language_translate('services_page_services_contract');?></span>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_subscription');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php echo form_dropdown('subscription', $subscriptionArray, array() , 'id="subscription" class="normal"' );?>
			</div>
		 </div>
		<div class="clear"></div>
	</div>	
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_sexual_orientation');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php echo form_dropdown('sexual_orientation', getSexualOrientationData_ioc(), array() , 'id="sexual_orientation" class="normal"' );?>
			</div>
		 </div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('services_page_where_do_you_work');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<table>
								<thead>
									<th><?php echo language_translate('services_page_table_head_country');?></th>
									<th><?php echo language_translate('services_page_table_head_state');?></th>
									<th><?php echo language_translate('services_page_table_head_province');?></th>
									<th><?php echo language_translate('services_page_table_head_city');?></th>
									<th><?php echo language_translate('services_page_table_head_price');?></th>
									<th><?php echo language_translate('services_page_table_head_action');?></th>
								</thead>
								<tbody>
									<?php
										foreach($listPlaceArray as $k =>$v):
										$placeInfo = getPlaceListDataInfoById($k);
										//echo multi_checkbox('list_place[]',$listPlaceArray,explode(',', $ESCORT->getPlacesListIdsContract()));					
									?>
										<?php if($placeInfo):?>
										<tr>
											<td>
												<?php echo $placeInfo['country'];?>
											</td>
											<td>
												<?php echo $placeInfo['state'];?>
											</td>
											<td>
												<?php echo $placeInfo['province'];?>
											</td>
											<td>
												<?php echo $placeInfo['city'];?>
											</td>
											<td>
												<?php echo $placeInfo['price'].' &euro;';?>
											</td>
											<td>
												<?php 
													$checked = '';
												?>
												<input type="checkbox" name="list_place[]" value="<?php echo $placeInfo['id'];?>" <?php echo $checked;?> class="custom" />
											</td>
										</tr>
										<?php endif;?>
									<?php endforeach; ?>
								</tbody>
							</table>
						</div>
					 </div>
					<div class="clear"></div>
				</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_add_a_pack');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php
					/* echo form_multiselect( 'list_pack[]',
										$options = $listPackArray,
										$selected = array(),
										" size='3' class=\"normal\" id='list_pack'"
									);
									*/
					echo multi_checkbox('list_pack[]',$listPackArray,array());				
				?>
			</div>
		 </div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_priority');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php
					echo multi_checkbox('list_priority[]',$listPriorityArray,array());				
				?>
			</div>
		 </div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_promotion_code');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<input type="text" name="promotion_code" id="promotion_code" value="" maxlength="45" class="text-box2">
			</div>
			<div class="input-error" id="promotion_code_err"></div>
		</div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_current');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<span style="float:left;"><?php echo loader_image_s('id="id_loader_pic" class="hidden"');?></span>
				<span id="current_price" style="float:left;">0 <?php echo language_translate('services_page_euro_monthly');?></span> 
			</div>
	  	</div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_payment_type');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php echo form_dropdown('payment_type', definePaymentType(), array() , 'id="payment_type" class="normal"' );?>
			</div>
		</div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_cardname');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<input type="text" name="cardname" id="cardname" value="" maxlength="45" class="text-box2"> 
			</div>
		</div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_creditcard');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<input type="text" name="creditcard" id="creditcard" value="" maxlength="45" class="text-box2"> 
			</div>
		</div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_month');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php echo dayMonthYearSelectBox(0, $dayID='day', $monthID= 'month', $yearID= 'year', $arrayReturn = array('m'), $extra='class="normal"');?>
			</div>
		</div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_year');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php echo dayMonthYearSelectBox(0, $dayID='day', $monthID= 'month', $yearID= 'year', $arrayReturn = array('y'), $extra='class="normal"');?>
			</div>
		</div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php echo language_translate('services_page_cvv');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<input type="text" name="cvv" id="cvv" value="" maxlength="45" class="text-box2"> 
			</div>
		</div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span>&nbsp;</span></div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<input type="submit" class="save-button" value="<?php echo language_translate('services_page_contract');?>" /> 
				<?php echo loader_image("id='loader_image' class='hidden'");?>
			</div>
		 </div>
		<div class="clear"></div>
	</div>	 
</div>

</form>

<div class="bottom-content-wrapper">
	<?php $this->load->view('news/list_news',array('pos'=>'service') ); ?> 
</div>
<div class="bottom-content-wrapper">
	<div class="bottom-content"></div>
</div>
		
		
<script type="text/javascript">
	$(document).ready(function() {
		var options = { 
			beforeSubmit:  validateB4Submit,  
			success:       processAfterResponding   
		};	
		$('#user_form').ajaxForm(options); 
		$('#subscription').live('change',function(){	//,#list_place,#list_pack
			updatePriceJS();
		});
		//$('input[name=list_pack\\[\\]]').live('click',function(){updatePrice();});
		//$('input[name=list_place\\[\\]]').live('click',function(){updatePrice();});
		$('.jquery-safari-checkbox').bind('click',function(){updatePriceJS();});
		updatePriceJS();
	});	
	
	function updatePriceJS(){
		$subscription_id = $('#subscription').val();
		$list_place = getMultiCheckbox('list_place');
		$list_pack = getMultiCheckbox('list_pack');
		$list_priority = getMultiCheckbox('list_priority');
		
		var price = 0;
		price += returnValueJSON(subs,$subscription_id);
		
		for(var i=0; i<$list_place.length; i++){
			price += returnValueJSON(place,$list_place[i]);
		}
		for(var i=0; i<$list_pack.length; i++){
			price += returnValueJSON(pack,$list_pack[i]);
		}
		for(var i=0; i<$list_priority.length; i++){
			price += returnValueJSON(priority,$list_priority[i]);
		}
		
		$('#current_price').html(price + EURO_MONTHLY);
	}
	
	function updatePrice(){
		$subscription_id = $('#subscription').val();
		$list_place = getMultiCheckbox('list_place');//$('#list_place').val();
		$list_place_id =  $list_place ? $list_place.join(','): '' ;
		$list_pack = getMultiCheckbox('list_pack');//$('#list_pack').val();
		$list_pack_id = $list_pack ? $list_pack.join(','): '';
		$list_priority = getMultiCheckbox('list_priority');
		$list_priority_id = $list_priority ? $list_priority.join(','): '';
		
		$('#id_loader_pic').show();
		$('#current_price').html('');
		$.post(BASE_URI+'registration/calculatePriceContract_asysn',{subscription_id:$subscription_id,list_place_ids:$list_place_id,list_pack_ids:$list_pack_id,list_priority_id:$list_priority_id},function(res){
			$('#current_price').html(res);
			$('#id_loader_pic').hide();
		});
	}
	 
	function validateB4Submit(formData, jqForm, options){
		$('#loader_image').show();
		return true;
	}

	function processAfterResponding(responseText, statusText, xhr, $form) {
		$('#loader_image').hide();	
		if(responseText == 'ok'){
			queryurl( BASE_URI+'registration/services_notify' );
		}else{
			var arr_res = responseText.split('#');
			for(i in arr_res){
				var e = arr_res[i].split('|');
				$('#'+e[0]).html(e[1]);
			}
		}
	}

</script>		
		